//
//  CleanView.m
//  intelligent
//
//  Created by Ace Portgas on 2024/3/5.
//

#import "CleanView.h"
@interface CleanView()
@end
@implementation CleanView

-(void)SQ_UIViewForSelfView{
    UIButton * backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    backBtn.frame = CGRectMake(0, 0, SCREEN_WIDETH, SCREEN_HEIGHT);
    backBtn.backgroundColor = [UIColor colorWithHexString:@"#000000" alpha:0.6];
    [backBtn addTarget:self action:@selector(clickHideView) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:backBtn];
    
    UIView * alertBackView = [UIView new];
    alertBackView.backgroundColor = [UIColor colorWithHexString:@"#ffffff"];
    alertBackView.layer.cornerRadius = 16;
    [backBtn addSubview:alertBackView];
    [alertBackView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(backBtn.mas_centerX);
        make.centerY.mas_equalTo(backBtn.mas_centerY);
        make.size.mas_offset(CGSizeMake(320, 134));
    }];
    
    UIImageView * imageView = [UIImageView new];
    imageView.image = SQGetImage(@"垃圾桶");
    [backBtn addSubview:imageView];
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_offset(CGSizeMake(88, 66));
        make.centerY.mas_equalTo(alertBackView.mas_top).offset(0);
        make.centerX.mas_equalTo(alertBackView.mas_centerX);
    }];
    
    UILabel * tipLabel = [UILabel new];
    tipLabel.text = SQNSLocalString(@"是否清除聊天记录");
    tipLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
    tipLabel.textColor = [UIColor colorWithHexString:@"#333333"];
    tipLabel.textAlignment = NSTextAlignmentCenter;
    [alertBackView addSubview:tipLabel];
    [tipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(alertBackView);
        make.centerY.mas_equalTo(alertBackView.mas_centerY);
    }];
    
    CGFloat btnW = (SCREEN_WIDETH - 15 - 80) / 2;
    UIButton * cleanBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    cleanBtn.backgroundColor = [UIColor colorWithHexString:@"#E8E8E8"];
    cleanBtn.layer.cornerRadius = 24;
    [cleanBtn setTitleColor:[UIColor colorWithHexString:@"#333333"] forState:UIControlStateNormal];
    [cleanBtn setTitle:SQNSLocalString(@"清除") forState:UIControlStateNormal];
    [cleanBtn addTarget:self action:@selector(clickFeedbackScore) forControlEvents:UIControlEventTouchUpInside];
    cleanBtn.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
    [backBtn addSubview:cleanBtn];
    [cleanBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(alertBackView.mas_bottom).mas_offset(20);
        make.right.mas_equalTo(self).mas_offset(-40);
        make.size.mas_offset(CGSizeMake(btnW, 48));
    }];
    
    UIButton * closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    closeBtn.backgroundColor = [UIColor colorWithHexString:@"#4AF8CE"];
    [closeBtn addTarget:self action:@selector(clickHideView) forControlEvents:UIControlEventTouchUpInside];
    closeBtn.layer.cornerRadius = 24;
    [closeBtn setTitleColor:[UIColor colorWithHexString:@"#333333"] forState:UIControlStateNormal];
    [closeBtn setTitle:SQNSLocalString(@"取消") forState:UIControlStateNormal];
    closeBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    [backBtn addSubview:closeBtn];
    [closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_offset(CGSizeMake(btnW, 48));
        make.top.mas_equalTo(alertBackView.mas_bottom).offset(20);
        make.left.mas_equalTo(self).offset(40);
    }];
}

-(void)clickFeedbackScore{
    if (self.clickCleanBlock) {
        self.clickCleanBlock();
    }
}

-(void)clickHideView{
    if (self.clickCancelBlock) {
        self.clickCancelBlock();
    }
}
@end
